/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dpy.appmvdpy.Facades;

import com.dpy.appmvdpy.Models.FormaPagamento;
import com.dpy.appmvdpy.Models.Vendedor;
import java.util.List;
import javax.persistence.Query;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Lilli
 */
@Component
@Scope(value="request")
public class FormaPagamentoFacade extends DefaultFacade<FormaPagamento> {
    
    public FormaPagamentoFacade()
    {
       super(FormaPagamento.class);
    }
     
    @Override
    public void setId(FormaPagamento entity) {
  //      entity.setId(this.getMaxId() + 1);
    }  
    
    @Transactional(readOnly=true)
    @Override
    public List<FormaPagamento> listAll()
    {
       Query q = em.createQuery("SELECT c from FormaPagamento as c ORDER BY c.descricao ASC");
       return q.getResultList();
    }
    
    @Transactional(readOnly=true)
    @Override
    public List<FormaPagamento> listAll(int pag)
    {
        Query q = em.createQuery("SELECT c from FormaPagamento as c ORDER BY c.descricao ASC");
       q.setFirstResult(pag * 100);
       q.setMaxResults(100);
       return q.getResultList();
    }
    
}
